
*Creates Table 2 from author digitized data. The original data are available in .pdf format at: https://achieve.lausd.net//site/Default.aspx?PageID=10329

cd "C:\Users\gilraine\OneDrive\Desktop\Old Laptop\LA Air Filters\JHR Data Repository\Air Testing Data and Code\"

clear all
import excel "Testing_Data.xlsx", sheet("Sheet1") firstrow

drop L
gen before_filter=1 if Date<td(28,1,2016)
replace before_filter=0 if Date>=td(5,2,2016)

*Create a dummy for two evacuated schools
gen evacuated=(SchoolName=="Castlebay Lane Charter School�" | SchoolName=="Porter Ranch Community School")

*Drop Stoney Point Continuation High as they shared testing with Chatsworth�Charter High School
drop if SchoolName=="Stoney Point Continuation High"

***Get Max for Table A.3***
preserve
gen count=1
collapse (max) Methane Ethane Benzene Toluene Ethylbenzene Xylenes Hydrogensulfide (count) count, by(SchoolName)
drop Hydrogensulfide
order SchoolName count Methane Ethane Benzene Toluene Ethylbenzene Xylenes 
restore


***TABLE 2****
*keep only schools observe before and after
egen before=max(before_filter), by(SchoolName)
egen after=min(before_filter), by(SchoolName)
drop if before==after
drop if evacuated==1

*DO BEFORE AND AFTER FOR EACH SCHOOL***
foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
su `var' if SchoolName=="Robert Frost Middle School" & before_filter==1 
su `var' if SchoolName=="Robert Frost Middle School" & before_filter==0
}

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
su `var' if SchoolName=="Van Gogh Charter" & before_filter==1
su `var' if SchoolName=="Van Gogh Charter" & before_filter==0
}

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
su `var' if SchoolName=="Beckford�Charter for Enriched Studies" & before_filter==1
su `var' if SchoolName=="Beckford�Charter for Enriched Studies" & before_filter==0
}

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
su `var' if SchoolName=="El Oro Way Charter for Enriched Sciences" & before_filter==1
su `var' if SchoolName=="El Oro Way Charter for Enriched Sciences" & before_filter==0
}

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
su `var' if SchoolName=="Darby�Avenue Charter" & before_filter==1
su `var' if SchoolName=="Darby�Avenue Charter" & before_filter==0
}

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
su `var' if SchoolName=="Germain Academy for Academic Achievement" & before_filter==1
su `var' if SchoolName=="Germain Academy for Academic Achievement" & before_filter==0
}

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
su `var' if SchoolName=="Knollwood Preparatory Academy" & before_filter==1
su `var' if SchoolName=="Knollwood Preparatory Academy" & before_filter==0
}

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
su `var' if SchoolName=="Superior Street Elementary" & before_filter==1
su `var' if SchoolName=="Superior Street Elementary" & before_filter==0
}

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
su `var' if before_filter==1
su `var' if before_filter==0
}

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
areg `var' before_filter, absorb(SchoolName) cluster(SchoolName)
boottest before_filter=0
}

gen after_filter=1 if before_filter==0
replace after_filter=0 if before_filter==1

foreach var of varlist Methane Benzene Toluene Ethylbenzene Xylenes{
areg `var' after_filter, absorb(SchoolName) cluster(SchoolName)
}


